import { defineDirective } from "@/shared/tools.mjs";

/**
 * @ngDirective <dev-only>
 */
export const devOnly = /* #__PURE__ */ defineDirective(() => ({
  // name: "dev-only",
  restrict: "A",
  /**
   * @param {ng.IScope} scope
   * @param {JQuery} element
   * @param {ng.IAttributes} attrs
   * @param {ng.IController=} controller
   * @param {ng.ITranscludeFunction=} transclude
   * @returns {void}
   */
  link(scope, element, attrs, controller, transclude) {
    // 这里假设你有一个全局变量来标识是否是开发环境，比如devMode
    transclude?.(
      scope,
      /**
       * @type {ng.ICloneAttachFunction}
       */
      (clonedElement, scope) => {
        // clonedElement?.appendTo(element);
        element.siblings();
        const [el] = element;
        [...(el?.parentNode?.children || [])].filter((child) => child !== el);
        // el.insertAdjacentHTML("beforebegin", "<div>dev-only</div>");
      },
    );
  },
}));
